var Mapper = require('../mysql/seque');

async function register(username, password, email) {
  return await Mapper.User.create({
    username: username,
    password: password,
    email: email
  });
};

async function selectUsersByPwdAndName(username, password) {
  return await Mapper.User.findOne({
    where: {
      username: username,
      password: password
    }
  });
};

async function selectUsersByName(username) {
  return await Mapper.User.findAll({
    where: {
      username: username
    }
  });
}

async function selectUserById(userid) {
  return await Mapper.User.findOne({
    where: {
      id: userid
    }
  });
}

module.exports = {
  register,
  selectUsersByPwdAndName,
  selectUsersByName,
  selectUserById
};